/**
 * Package name:indi.yangshenhui.hbase.test
 * File name:RuJiaScanMain.java
 * Date:2016年4月9日-下午6:20:10
 * feiniu.com Inc.Copyright (c) 2013-2015 All Rights Reserved.
 *
 */
package indi.yangshenhui.hbase.test;

import java.util.List;

import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.filter.FilterList.Operator;
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
import org.apache.hadoop.hbase.util.Bytes;

import com.alibaba.fastjson.JSON;

import indi.yangshenhui.hbase.dao.HBaseBaseDao;
import indi.yangshenhui.hbase.dao.HBaseDaoImpl;
import indi.yangshenhui.hbase.dao.constant.HBaseConstant;
import indi.yangshenhui.hbase.dao.entity.HBaseQueryEntity;
import indi.yangshenhui.hbase.dao.exception.HBaseDaoException;
import indi.yangshenhui.hbase.dao.pool.HTablePoolEngine;
import indi.yangshenhui.tool.CheckUtil;

/**
 * @ClassName RuJiaScanMain
 * @Description
 * @date 2016年4月9日 下午6:20:10
 * @author shenhui
 * @version 1.0.0
 *
 */
public class RuJiaScanMain {

	public static void main(String[] args) throws HBaseDaoException {
		HTablePoolEngine.createHBaseConfiguration(HBaseConstant.HBASE_DEFAULT_INSTANCE, "ubuntu-1,ubuntu-2,ubuntu-3",
				"2181");

		long start = System.currentTimeMillis();
		long stop = 0L;
		HBaseQueryEntity hBaseQueryEntity = new HBaseQueryEntity();
		hBaseQueryEntity.setCache(false);
		hBaseQueryEntity.setCacheSize(10);
		hBaseQueryEntity.setFilterOperator(Operator.MUST_PASS_ALL);
		hBaseQueryEntity.addColumn("f", "name");
		hBaseQueryEntity.addColumn("f", "ctfId");
		hBaseQueryEntity.addColumn("f", "address");
		hBaseQueryEntity.addColumn("f", "birthday");
		hBaseQueryEntity.addColumn("f", "nation");

		hBaseQueryEntity.addFilter(new SingleColumnValueFilter(Bytes.toBytes("f"), Bytes.toBytes("name"),
				CompareOp.EQUAL, Bytes.toBytes("朱志强")));
		// hBaseQueryEntity.setPrefixRowKey("5");
		// hBaseQueryEntity.setTimeStamp(1403278678033L);
		hBaseQueryEntity.setMaxRows(Integer.MAX_VALUE);
		HBaseBaseDao hBaseDao = new HBaseDaoImpl();
		List<RuJiaPojo> list = hBaseDao.queryObject(RuJiaPojo.class, hBaseQueryEntity);
		CheckUtil.checkNull(list);
		System.out.println(JSON.toJSONString(list));
		stop = System.currentTimeMillis();
		System.err.println("total cost = " + (stop - start) + " ms");
	}

}
